Xbasic

SQL_QueryImport Function

Syntax

ResultObject as P = SQL_QueryImport(P SqlConn ,C query ,C localfilename [,* TableInfo [,L ShowProgress [,L AllowCancel [,L AddTableToDatabase [,* ArgumentsPassedIn [,C StatusBarFormatString ]]]]]])

Arguments

ResultObject

Returns the result of the action. The following properties are returned:

.HasError = .T. if there was an error, .F. if the query was imported
.ErrorText = contains the error text if there was an error
.UserCancelled = .T. if the user cancelled before the import completed
SqlConn

A SQL::Connection object.

query

A SQL SELECT query that selects records from the target database.

localfilename

The path and name of the local Alpha Anywhere .DBF table to create.

TableInfo

A SQL::TableInfo object. If you do not need to specify a value for this argument enter null_value().

ShowProgress

Logical. Optional. Indicates whether to show a progress dialog. Default is .T.

AllowCancel

Logical. Optional. Indicates whether the user is allowed to cancel the import before it has completed. Default is .T.

AddTableToDatabase

Logical. Optional. Indicates whether the local table should be added to the local Database (i.e. the .adb file). Default is .T. (If you don't need the table to be part of the local Database, you can save time by setting this flag to .F.)

ArgumentsPassedIn

If your query references any arguments, you can pass in values for these arguments. If you do not need to specify a value for this argument, enter null_value().

StatusBarFormatString

Character

Description

Import a SQL query into a DBF table. Optionally adds the table to the current database.

Discussion

The SQL_QueryImport() function imports a table from a back-end SQL database into an Alpha Anywhere .DBF table.

Example

dim cn as sql::connection
dim cs as c 
cs = "Your connection string goes here"
dim sqlquery as c 
sqlquery = "select * from customers where city = :whatCity"
dim args as sql::arguments
args.set("whatCity","London")

dim flag as l 
flag = cn.open(cs)
if flag = .f. then 
     ui_msg_box("Error","Could not connect: " + cn.callresult.text)
     end 
end if 

dim resultP as p 
resultP = SQL_QueryImport(cn,sqlquery,"c:\data\customers.dbf",null_value(),.t.,.t.,.t.,Args)

Limitations

Desktop applications only.

See Also